package taller2.controller.MainEdittingMenu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import taller2.view.components.ResizeBar;
import taller2.view.windows.MainWindows.MainWindow;

public class AreaSizeListener implements ChangeListener, ActionListener{
	protected MainWindow window;
	protected ResizeBar bar;
	protected float tam;
	
	// constructor
	public AreaSizeListener(MainWindow window, ResizeBar bar) {
		this.window = window;
		this.bar = bar;
		this.tam = (float)0.5;
	}
	
	// changes the size given to the graph drawing and pseudocode
	// acordingly
	public void actionPerformed(ActionEvent event) {
		window.rebalanceWindow(tam);
		bar.unselectButtons();
	}
	
	// detects when user changes the size of the bar
	public void stateChanged(ChangeEvent e) {
		int value = ((JSlider)e.getSource()).getValue();
		tam = ((float)value)/100;	
	}
}
